Git & GitHub Cheatsheet

November 28, 2022

Git Config

Configures user information used across all local repositories.

git config --global user. name "username"

git config --global user. email "email"

Git Init

Create an empty Git repository or reinitialize an existing one

git init

Git Clone

Clone a repository into a new directory

git clone [url]

Git Add

Add file contents to the index

git add file-name
git add *
git add .

Git Commit

Record changes to the repository

git commit -m "Commit message"

Git Push

Update remote refs along with associated objects

git push origin master

Git Status

Show the working tree status

git status

Git Remote

Connect to the remote repository

git remote add origin master

Git Branch

List, create, or delete branches

git branch

Git Pull Request

Fetch from and integrate with another repository or a local branch

git pull

Git Merge Request

Join two or more development histories together

git merge

Git Log

Show commit logs

git log

Git Reset

Reset current HEAD to the specified state

git reset

Git Stash

Stash the changes in a dirty working directory away

git stash

Git Tag

Create, list, delete or verify a tag object signed with GPG

git tag

Git Checkout

Switch branches or restore working tree files

git checkout

Git Rebase

Reapply commits on top of another base tip

git rebase

Git Fetch

Download objects and refs from another repository

git fetch

Git Diff

Show changes between commits, commit and working tree, etc

git diff

Git Archive

Create an archive of files from a named tree

git archive

Git Submodule

Initialize, update or inspect submodules

git submodule

Git Bisect

Use binary search to find the commit that introduced a bug

git bisect

Git Cherry-Pick

Apply the changes introduced by some existing commits

git cherry-pick

Git Revert

Revert some existing commits

git revert

Git Clean

Remove untracked files from the working tree

git clean

Git Rm

Remove files from the working tree and from the index

git rm

Git Show

Show various types of objects

git show

Git Shortlog

Summarize git log output

git shortlog

Git Describe

Show the most recent tag that is reachable from a commit

git describe

Git Reflog

Manage reflog information

git reflog

Git Filter-Branch

Rewrite branches

git filter-branch

Git Rev-List

Lists commit objects in reverse chronological order

git rev-list

Git Instaweb

Instantly browse your working repository in gitweb

git instaweb

Profile picture

Written by Manthan Ankolekar who lives and works in Karnataka, India. You should follow them on Twitter